

using System;
using System.Collections.Generic;
using System.Text;
using EntityLayer;
using System.Data;
using DataAccessLayer;
using InfraStructureLayer;

namespace DataLayer
{
	public class datArticleContents
	{
		public datArticleContents()
		{
		}

        #region  Code Factory Generated Methods
        public void DeleteArticleContentsByArticleContentId(entArticleContents parEntArticleContents, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pArticleContentId", parEntArticleContents.ArticleContentId);
            parDbConnector.ExecuteNonQuery("DeleteArticleContentsByArticleContentId", insDbParamCollection);
        }
        
        #endregion
        public DataTable SelectArticleContentsByArticleId(entArticleContents parEntArticleContents, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pArticleId", parEntArticleContents.ArticleId);
            return parDbConnector.ExecuteDataTable("SelectArticleContentsByArticleId", insDbParamCollection);
        }
        public void InsertArticleContents(entArticleContents parEntArticleContents, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pArticleId", parEntArticleContents.ArticleId);
            insDbParamCollection.Add("@pLanguageId", parEntArticleContents.LanguageId);
            insDbParamCollection.Add("@pArticleTitle", parEntArticleContents.ArticleTitle);
            insDbParamCollection.Add("@pArticleSummary", parEntArticleContents.ArticleSummary);
            insDbParamCollection.Add("@pArticleBody", parEntArticleContents.ArticleBody);
            insDbParamCollection.Add("@pArticleSummaryText", parEntArticleContents.ArticleSummaryText);
            insDbParamCollection.Add("@pArticleBodyText", parEntArticleContents.ArticleBodyText);
            insDbParamCollection.Add("@pArticleReadCount", 0);
            insDbParamCollection.AddOutput("@pArticleContentId", DbType.Int32);
            parDbConnector.ExecuteNonQuery("InsertArticleContents", insDbParamCollection);
            parEntArticleContents.ArticleContentId = Convert.ToInt32(insDbParamCollection.GetOutPutParameter().Value);
        }
        public void UpdateArticleContentsByArticleContentId(entArticleContents parEntArticleContents, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pArticleContentId", parEntArticleContents.ArticleContentId);

            insDbParamCollection.Add("@pArticleId", parEntArticleContents.ArticleId);
            insDbParamCollection.Add("@pLanguageId", parEntArticleContents.LanguageId);
            insDbParamCollection.Add("@pArticleTitle", parEntArticleContents.ArticleTitle);
            insDbParamCollection.Add("@pArticleSummary", parEntArticleContents.ArticleSummary);
            insDbParamCollection.Add("@pArticleBody", parEntArticleContents.ArticleBody);
            insDbParamCollection.Add("@pArticleSummaryText", parEntArticleContents.ArticleSummaryText);
            insDbParamCollection.Add("@pArticleBodyText", parEntArticleContents.ArticleBodyText);
            parDbConnector.ExecuteNonQuery("UpdateArticleContentsByArticleContentId", insDbParamCollection);
        }
        public void SelectArticleContentsByArticleContentId(entArticleContents parEntArticleContents, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pArticleContentId", parEntArticleContents.ArticleContentId);
            DataTable insDataTable = new DataTable();
            insDataTable = parDbConnector.ExecuteDataTable("SelectArticleContentsByArticleContentId", insDbParamCollection);
            if (insDataTable.Rows.Count > 0)
            {
                if (insDataTable.Rows[0]["ArticleContentId"] != DBNull.Value)
                {
                    parEntArticleContents.ArticleContentId = Convert.ToInt32(insDataTable.Rows[0]["ArticleContentId"]);
                }
                if (insDataTable.Rows[0]["ArticleId"] != DBNull.Value)
                {
                    parEntArticleContents.ArticleId = Convert.ToInt32(insDataTable.Rows[0]["ArticleId"]);
                }
                if (insDataTable.Rows[0]["LanguageId"] != DBNull.Value)
                {
                    parEntArticleContents.LanguageId = Convert.ToInt32(insDataTable.Rows[0]["LanguageId"]);
                }
                if (insDataTable.Rows[0]["ArticleTitle"] != DBNull.Value)
                {
                    parEntArticleContents.ArticleTitle = insDataTable.Rows[0]["ArticleTitle"].ToString();
                }
                if (insDataTable.Rows[0]["ArticleSummary"] != DBNull.Value)
                {
                    parEntArticleContents.ArticleSummary = insDataTable.Rows[0]["ArticleSummary"].ToString();
                }
                if (insDataTable.Rows[0]["ArticleBody"] != DBNull.Value)
                {
                    parEntArticleContents.ArticleBody = insDataTable.Rows[0]["ArticleBody"].ToString();
                }
                if (insDataTable.Rows[0]["ArticleReadCount"] != DBNull.Value)
                {
                    parEntArticleContents.ArticleReadCount = Convert.ToInt32(insDataTable.Rows[0]["ArticleReadCount"]);
                }
            }
        }
        public void SelectArticleContentsByArticleIdAndLanguageId(entArticleContents parEntArticleContents, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pArticleId", parEntArticleContents.ArticleId);
            insDbParamCollection.Add("@pLanguageId", CurrentContext.LanguageId);
            DataTable insDataTable = new DataTable();
            insDataTable = parDbConnector.ExecuteDataTable("SelectArticleContentsByArticleIdAndLanguageId", insDbParamCollection);
            if (insDataTable.Rows.Count > 0)
            {
                if (insDataTable.Rows[0]["ArticleContentId"] != DBNull.Value)
                {
                    parEntArticleContents.ArticleContentId = Convert.ToInt32(insDataTable.Rows[0]["ArticleContentId"]);
                }
                if (insDataTable.Rows[0]["ArticleId"] != DBNull.Value)
                {
                    parEntArticleContents.ArticleId = Convert.ToInt32(insDataTable.Rows[0]["ArticleId"]);
                }
                if (insDataTable.Rows[0]["LanguageId"] != DBNull.Value)
                {
                    parEntArticleContents.LanguageId = Convert.ToInt32(insDataTable.Rows[0]["LanguageId"]);
                }
                if (insDataTable.Rows[0]["ArticleTitle"] != DBNull.Value)
                {
                    parEntArticleContents.ArticleTitle = insDataTable.Rows[0]["ArticleTitle"].ToString();
                }
                if (insDataTable.Rows[0]["ArticleSummary"] != DBNull.Value)
                {
                    parEntArticleContents.ArticleSummary = insDataTable.Rows[0]["ArticleSummary"].ToString();
                }
                if (insDataTable.Rows[0]["ArticleBody"] != DBNull.Value)
                {
                    parEntArticleContents.ArticleBody = insDataTable.Rows[0]["ArticleBody"].ToString();
                }
                if (insDataTable.Rows[0]["ArticleReadCount"] != DBNull.Value)
                {
                    parEntArticleContents.ArticleReadCount = Convert.ToInt32(insDataTable.Rows[0]["ArticleReadCount"]);
                }
            }
        }
        public void UpdateArticleContentRead(entArticleContents parEntArticleContents, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pArticleContentId", parEntArticleContents.ArticleContentId);
            parDbConnector.ExecuteNonQuery("UpdateArticleContentRead", insDbParamCollection);
        }
	}
}